//
//  JXStatusViewModel.swift
//  01-weiboSwift
//
//  Created by TwistFate on 16/3/2.
//  Copyright © 2016年 TwistFate. All rights reserved.
//

import UIKit

class JXStatusViewModel: NSObject {
    
    func loadStatus (loadStatusCallBack:(statuses : [JXStatus]? , error : NSError?)->()) {
        JXNetworkTool.sharedInstance.loadStatus { (result, error) -> () in
            if error != nil {
                
                loadStatusCallBack(statuses :nil ,error:error)
                
                return
            }
            
            if let array = result?["statuses"] as? [[String:AnyObject]] {
            
                var statuses = [JXStatus]()
                
                for dict in array {
                    let status = JXStatus(dict: dict)
                    statuses.append(status)
//
                }
                
                loadStatusCallBack(statuses :statuses ,error:nil)
            }else{
                loadStatusCallBack(statuses :nil ,error:nil)
            }
            
        }
        
    }
    
}
